package homework1

import org.apache.kafka.clients.producer.{KafkaProducer, ProducerConfig}
import org.apache.kafka.common.serialization.StringSerializer

import java.util.Properties

object KafkaProducer extends Serializable {

  val brokers = "196.168.8.103:9092,196.168.8.104:9092,196.168.8.105:9092"
  val topic = "topic2"
  val prop = new Properties()

  prop.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers)
  prop.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
  prop.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])

  // KafkaProducer
//  var producer = new KafkaProducer[String, String](prop)

  def instance(): KafkaProducer[String, String] = new KafkaProducer[String, String](prop)

}
